Measure rotational period, frequency, and angular speed using either Gate A or Gate B.
Period T = N Δt (N: Number of Slits)Frequency f = 1/TAngular Speed ω = 2πf
Δt is calculated from consecutive midpoint timestamps from the same gate: Δt = t₂ − t₁. The displayed time is (t₁ + t₂)/2. Arduino blocking durations are ignored. The first reading from each gate initializes the timestamp and does not create a measurement.
Status: Arduino not connected
Raw Serial Data
Latest Measurement
Measurement
Value
Gate
---
Time t (s)
---
Time Interval Δt (s)
---
Period T (s)
---
Frequency f (Hz)
---
Angular Speed ω (rad/s)
---
Angular Speed vs. Time
Measurement Data
No.
Gate
Time t (s)
Δt (s)
Period T (s)
f (Hz)
ω (rad/s)
Copy Data places tab-separated values on the clipboard so they can be pasted directly into Excel. The table displays the latest 300 measurements; Copy Data includes all retained measurements (up to 100,000).
按下 Copy Data 可將以定位字元分隔的數據複製到剪貼簿,直接貼入 Excel。表格顯示最新的 300 筆量測資料;Copy Data 則會包含所有保留的量測資料(最多 100,000 筆)。
This web application was developed with AI assistance for NTHU General Physics Laboratory. Program development: Lab Maker Project.
Arduino Example Program
/*
Photogate Timer for NTHU General Physics Laboratory.
This program uses two photogates (Gate A and Gate B) to measure the motion of an object.
For each photogate, the program records:
1. Time: the midpoint time of the blocking interval (s)
2. Δt: the duration that the photogate is blocked (s)
Output example:
Gate A: 1.253426, 0.018532
Gate B: 1.684720, 0.017916
For rotational motion, the web page uses consecutive midpoint times from the same gate.
The interval is Δt = t2 - t1 and its time is (t1 + t2)/2.
The Arduino blocking duration is ignored.
Then T = N * Δt, f = 1/T, and angular speed = 2*pi*f.
*/
int gatePinA = 2; // Photogate A: digital pin 2
int gatePinB = 3; // Photogate B: digital pin 3
int ledPin = 13; // Built-in LED
int gatemode = LOW; // LOW when the photogate is blocked. Change to HIGH if needed.
unsigned long t0; // Starting time
unsigned long tNew, tLast; // Entering and leaving times
float time, deltat; // Midpoint time and blocking duration (s)
void setup() {
Serial.begin(115200); // Start serial communication
pinMode(gatePinA, INPUT_PULLUP); // Gate A input (keep HIGH when disconnected)
pinMode(gatePinB, INPUT_PULLUP); // Gate B input (keep HIGH when disconnected)
pinMode(ledPin, OUTPUT); // LED as output
t0 = micros(); // Set the starting time
}
void loop() {
// Gate A
if (digitalRead(gatePinA) == gatemode) { // Gate A is blocked
tNew = micros(); // Object enters Gate A
digitalWrite(ledPin, HIGH); // LED on
while (digitalRead(gatePinA) == gatemode) { ; } // Wait until object leaves
tLast = micros(); // Object leaves Gate A
deltat = (tLast - tNew) / 1000000.0; // Blocking duration (s)
time = (tNew - t0) / 1000000.0 + deltat / 2.0; // Midpoint time (s)
digitalWrite(ledPin, LOW); // LED off
Serial.print("Gate A: ");
Serial.print(time, 6); // Midpoint time (s)
Serial.print(", ");
Serial.println(deltat, 6); // Blocking duration (s)
}
// Gate B
if (digitalRead(gatePinB) == gatemode) { // Gate B is blocked
tNew = micros(); // Object enters Gate B
digitalWrite(ledPin, HIGH); // LED on
while (digitalRead(gatePinB) == gatemode) { ; } // Wait until object leaves
tLast = micros(); // Object leaves Gate B
deltat = (tLast - tNew) / 1000000.0; // Blocking duration (s)
time = (tNew - t0) / 1000000.0 + deltat / 2.0; // Midpoint time (s)
digitalWrite(ledPin, LOW); // LED off
Serial.print("Gate B: ");
Serial.print(time, 6); // Midpoint time (s)
Serial.print(", ");
Serial.println(deltat, 6); // Blocking duration (s)
}
}